#include <stdio.h>
#include <signal.h>
#include <iostream>
#include <unistd.h>
#include <sys/time.h>
using namespace std;
void alaramOperator(int n){
    cout << "Alaram" << endl;
}

void testAlaram(){
    cout << "sleep 4 second" <<endl;
    signal(SIGALRM,alaramOperator);
    struct itimerval new_timer;
    new_timer.it_value.tv_sec = 1;
    new_timer.it_value.tv_usec = 0;

    new_timer.it_interval.tv_sec = 1;
    new_timer.it_interval.tv_usec = 0;
    setitimer(ITIMER_REAL,&new_timer,0);

    while(true){
        pause();
    }
    cout << "signal alaram complete" << endl;

}
